-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to Remove Lower and Upper Bounds from Models #459
base: main
Are you sure you want to change the base?
Conversation
…dd tests to check for its functionality
…dd tests to check for its functionality
…w ConfigurableMixin class
…hods from models/base to strategy
Moving the methods (like I think what should happen is the -- I'm not convinced that inducing_points should be a separate argument for models. There's multiple reasons:
Given that all three arguments appear to be strictly for inducing points, we should try to encapsulate it all in InducingPointAllocator (or at least the one argument). I think the best way to do this is to require a -- Not actually sure why that test is failing. Nothing should have changed that. Did adding data to models somehow change? It should be easily higher than the 0.3 threshold (it should be around 0.5, looking at the code). Wait for @crasanders opinion on direction before moving on. |
I like the idea of making the
I agree that we should get rid of
I'll take a closer look after these other changes have been made. |
Description:
This refactor addresses issue #379 where AEPsych models currently depend on lower and upper bounds (
lb
andub
) being passed into their constructors. The goal is to shift the responsibility of managing bounds to the strategy, allowing models to focus solely on the dimensionality of the space. This change reduces boilerplate and improves flexibility, as bounds are now passed as parameters when needed, rather than being stored within the model itself.LookAhead:
GlobalLookaheadAcquisitionFunction
class and its subclasses to acceptlb
andub
fromOptimizeAcqfGenerator
, as it relied onmodel.ub
andmodel.lb
to computeXq
before. However, this information was already passed to theOptimizeAcqfGenerator
.OptimizeAcqfGenerator
to initialize the acquisition functions that requirelb
andub
with these parameters.MonotonicRejectionGenerator
and other generators to acceptlb
andub
directly and not rely onmodel.lb
andmodel.ub
.In
models/base.py
- Massive Refactor:Moving Methods to
Strategy
:get_max
,get_min
, andinv_query
methods toStrategy
, as these methods rely on havinglb
andub
in the model.get_jnd
toStrategy
, as it is not needed in the models but only in the strategy.Dim Grid Handling:
dim_grid
was moved toStrategy
, but it was kept inbase.py
temporarily asPairwiseProbitModel
is not yet refactored to not uselb
andub
(this should be handled in a separate PR).aepsych.utils
and can simply be called in theStrategy
itself.Simplified
AEPsychMixin
:AEPsychMixin
paves the way for the next PR.Enhancements in
Strategy
:Strategy
to be called from the original methods._is_first_fit
was added to ensure that it fits the first time around and doesn’t skip that step before updating right away.In Models:
Transition from
lb
andub
toinducing_points
:PairwiseProbitModel
) that previously relied onlb
andub
are now moved to working withinducing_points
.Conditions for
inducing_points
:SobolAllocator
is provided:SobolAllocator
is provided:dim
is provided:SobolAllocator
is provided).dim
is None:dim
will be inferred from the shape of the points tensor.NOTE: The focus on
SobolAllocator
is that it does not require input (unlike the other allocators) and cannot be initialized with them unless data is passed at the beginning, which is uncommon.NOTE2: in
MonotonicProjectionGP
,self.lb[dim]
was replaced withself.inducing_points.min(dim=0).values
.Inducing Point Method:
AutoAllocator
.Tests:
Tests have been structured around the changes and refactors made in the codebase, focusing on initialization, inducing points, and configurations.
Tests Related to Initialization and Inducing Points:
tests/acquisition/test_mi.py
tests/generators/test_epsilon_greedy_generator.py
These tests verify the initialization and the calculation of inducing points. The inducing points were calculated as before (using
SobolAllocator
), but instead of being computed within the model’s class, they are now calculated prior to initialization and passed directly to the model from the generator.Tests Related to Configurations and Dummy Inducing Points:
tests/models/test_gp_regression.py
tests/models/test_monotonic_projection_gp.py
tests/test_config.py
These tests focus on configurations, ensuring that the
dim
parameter is provided to create the dummy inducing points when no inducing points are explicitly given. In some cases, the allocator (e.g.,SobolAllocator
) is used for initialization, but it is not desired for the entire lifecycle of the model—just for the initial allocation of points.Note: One test case has been failing and I am not sure why, in:
Where it originated from this condition not being met with start.finished method:
is approximately
0.1
, while the threshold set before is0.3
.I would love to hear your thoughts on the root of this issue.